var load = 1;
var page = 1;
$(function(){
    // 矿机商城
    $.ajax({
        type:"post",
        url:url+'/profile/rentminepage.html?token='+token,
        async:true,
        data:{'token':token},
        dataType:'json',
        success:function(result){
            // console.log(result)
            if(result.status === "0001"){
                var data = result.data;
                var html = "";
                if(data.length > 0){
                    for(var i = 0;i < data.length;i++){
                        var o = data[i];
                        html += `
                        <li class="shopp_tiem">
                            <div class="shopp_top">
                                <img src="${o.img}" alt="" class="shopp_img" />
                                <p class="shopptop_title">
                                    型号：${o.name}<br />
                                    寿命：${o.life}小时<br />
                                    产量：${o.output}/小时<br />
                                    总产量：${o.total_reve} 
                                </p>
                            </div>
                            <div class="shopp_bot">
                                <p class="shoppbot_title">价格：${o.price} 节点钱包</p>
                                <a href="javascript:passw(${o.id},${o.price});" class="shoppbot_link">立即租用</a>
                            </div>
                        </li>`
                    }
                    $(".shopp_list").append(html);
                }else{
                    load = 0;
                    html += "<li style='text-align:center;display:block;margin-top:1rem;'>暂无数据</li>";
                    $(".shopp_list").html(html);
                }
            }else{
                isErr(result)
            }
        },
        error:function(){
            layer.msg("响应失败");
        }
    })
    paged(page)

    function paged(page){
        // 租用记录
        $.ajax({
            type:"post",
            url:url+'/profile/rentrecord.html?token='+token,
            async:true,
            data:{'token':token,"page":page},
            dataType:'json',
            success:function(result){
                // console.log(result)
                if(result.status === "0001"){
                    var data = result.data;
                    var html = "";
                    if(data.length > 0){
                        for(var i = 0;i < data.length;i++){
                            var o = data[i];
                            html += `
                            <li class="sh_item">
                                <div class="shitem_le">
                                    <p class="shitem_let">${o.car_name}</p>
                                    <p class="shitem_let">${o.create_at}</p>
                                </div>
                                <p class="shitem_title">使用${o.price} 节点钱包</p>
                            </li>`
                        }
                        if(data.length < 15){
                            load = 0;
                            html += "<li class='noMoreMsg' style='text-align:center;display:block;margin-bottom:.2rem;'>暂无数据</li>"; 
                        }
                        $(".sh_list").append(html);
                    }else{
                        load = 0;
						html += "<li class='noMoreMsg' style='text-align:center;display:block;margin-bottom:.2rem;'>暂无数据</li>";
						$(".sh_list").append(html);
					}
                }else{
    
                }
            },
            error:function(){
                layer.msg("响应失败");
            }
        })
    }
    
   // 下拉加载更多
   $(window).scroll(function () {
    if ($(document).scrollTop() >= $(document).height() - $(window).height() - 1) {
        if (load == 1) {
            page++;
            paged(page)
        }
    }
});
})

